package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rpcinterface/client/pay"
	"github.com/robfig/cron"
	"time"
)

func sandAgentShareCard() {
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("crontab.log.sandAgentShareCard"))
	rpcPay := new(pay.Pay).Init()
	args := int(time.Now().Local().Unix())
	reply := false
	if err := rpcPay.SandAgentShareCard(context.Background(), &args, &reply); err != nil {
		utils.Logerr.Printf("共享卡资金通过杉德支付渠道代付失败, 错误信息:%v.", err.Error())
	}
	//utils.Logerr.Printf("共享卡资金通过杉德支付渠道代付完成.")
}

func sandAgentFundShareCard() {
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("crontab.log.sandAgentFundShareCard"))
	rpcPay := new(pay.Pay).Init()
	args := int(time.Now().Local().Unix())
	reply := false
	if err := rpcPay.SandAgentFundShareCard(context.Background(), &args, &reply); err != nil {
		utils.Logerr.Printf("共享卡资金通过杉德支付渠道查询代付结果失败, 错误信息:%v.", err.Error())
	}
	//utils.Logerr.Printf("共享卡资金通过杉德支付渠道查询代付结果完成.")
}

func main() {
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	c := cron.New()
	//每天18:30执行
	_ = c.AddFunc("0 30 18 * * ?", sandAgentShareCard)
	//每天19:00执行
	_ = c.AddFunc("0 0 19 * * ?", sandAgentFundShareCard)
	c.Start()
	select {}
}
